package com.yyw.Service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yyw.bean.Accusation;
import com.yyw.dao.AccusationDao;
import com.yyw.util.Result;
import com.yyw.util.ResultFactory;

@Service
public class AccusationService {

    @Autowired
    private AccusationDao accusationDao;

    /**
     * 保存举报
     *
     * @param accusation
     * @return
     */
    public Result saveAccusation(Accusation accusation) {
        // 数据校验
        if (!accusation.check()) {
            return ResultFactory.notice("数据不合法");
        }
        int result = accusationDao.saveAccusation(accusation);
        if (result > 0) {
            return ResultFactory.success("添加成功");
        } else {
            return ResultFactory.failure("添加失败");
        }
    }
}
